import React from 'react'
import { NavBar, Icon } from 'antd-mobile';
// 导入withRouter高阶组件
import { withRouter } from 'react-router-dom'
import PropTypes from 'prop-types'

function navHeader({ children, history, onLeftClick }) {
    const defaultHandler = () => history.go(-1)
    return (
        <NavBar
                className="nanbar"
                mode="dark"
                icon={<Icon type="left" />}
                onLeftClick={onLeftClick || defaultHandler}
        >{ children }</NavBar>
    )
}
// 添加props校验
navHeader.propTypes = {
    children: PropTypes.string.isRequired,
    onLeftClick: PropTypes.func
}
export default withRouter(navHeader)
